
function check_form() {
	var error_message = "<?php echo JS_ERROR; ?>";
	var error_found = false;
	var error_field;
	var keywords = document.advanced_search.keywords.value;
	var dfrom = document.advanced_search.dfrom.value;
	var dto = document.advanced_search.dto.value;
	var pfrom = document.advanced_search.pfrom.value;
	var pto = document.advanced_search.pto.value;
	var pfrom_float;
	var pto_float;
	
	if ( ((keywords == '') || (keywords.length < 1)) && ((dfrom == '') || (dfrom == '<?php echo DOB_FORMAT_STRING; ?>') || (dfrom.length < 1)) && ((dto == '') || (dto == '<?php echo DOB_FORMAT_STRING; ?>') || (dto.length < 1)) && ((pfrom == '') || (pfrom.length < 1)) && ((pto == '') || (pto.length < 1)) ) {
		error_message = error_message + "* <?php echo ERROR_AT_LEAST_ONE_INPUT; ?>\n";
		error_field = document.advanced_search.keywords;
		error_found = true;
	}
	
	if ((dfrom.length > 0) && (dfrom != '<?php echo DOB_FORMAT_STRING; ?>')) {
		if (!IsValidDate(dfrom, '<?php echo DOB_FORMAT_STRING; ?>')) {
			error_message = error_message + "* <?php echo ERROR_INVALID_FROM_DATE; ?>\n";
			error_field = document.advanced_search.dfrom;
			error_found = true;
		}
	}
	
	if ((dto.length > 0) && (dto != '<?php echo DOB_FORMAT_STRING; ?>')) {
		if (!IsValidDate(dto, '<?php echo DOB_FORMAT_STRING; ?>')) {
			error_message = error_message + "* <?php echo ERROR_INVALID_TO_DATE; ?>\n";
			error_field = document.advanced_search.dto;
			error_found = true;
		}
	}
	
	if ((dfrom.length > 0) && (dfrom != '<?php echo DOB_FORMAT_STRING; ?>') && (IsValidDate(dfrom, '<?php echo DOB_FORMAT_STRING; ?>')) && (dto.length > 0) && (dto != '<?php echo DOB_FORMAT_STRING; ?>') && (IsValidDate(dto, '<?php echo DOB_FORMAT_STRING; ?>'))) {
		if (!CheckDateRange(document.advanced_search.dfrom, document.advanced_search.dto)) {
			error_message = error_message + "* <?php echo ERROR_TO_DATE_LESS_THAN_FROM_DATE; ?>\n";
			error_field = document.advanced_search.dto;
			error_found = true;
		}
	}
	
	if (pfrom.length > 0) {
		pfrom_float = parseFloat(pfrom);
		
		if (isNaN(pfrom_float)) {
			error_message = error_message + "* <?php echo ERROR_PRICE_FROM_MUST_BE_NUM; ?>\n";
			error_field = document.advanced_search.pfrom;
			error_found = true;
		}
	} else {
		pfrom_float = 0;
	}
	
	if (pto.length > 0) {
		pto_float = parseFloat(pto);
		
		if (isNaN(pto_float)) {
			error_message = error_message + "* <?php echo ERROR_PRICE_TO_MUST_BE_NUM; ?>\n";
			error_field = document.advanced_search.pto;
			error_found = true;
		}
	} else {
		pto_float = 0;
	}
	
	if ( (pfrom.length > 0) && (pto.length > 0) ) {
		if ( (!isNaN(pfrom_float)) && (!isNaN(pto_float)) && (pto_float < pfrom_float) ) {
			error_message = error_message + "* <?php echo ERROR_PRICE_TO_LESS_THAN_PRICE_FROM; ?>\n";
			error_field = document.advanced_search.pto;
			error_found = true;
		}
	}
	
	if (error_found == true) {
		alert(error_message);
		error_field.focus();
		return false;
	} else {
		RemoveFormatString(document.advanced_search.dfrom, "<?php echo DOB_FORMAT_STRING; ?>");
		RemoveFormatString(document.advanced_search.dto, "<?php echo DOB_FORMAT_STRING; ?>");
		return true;
	}
}

function popupWindow(url) {
	window.open(url, 'popupWindow', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,left=150');
	return false;
}

function resize() {
	var i = 0;
	
	if (navigator.appName == 'Netscape')
		i = 40;
	
	if (document.images[0])
		window.resizeTo(document.images[0].width +30, document.images[0].height+60-i);
	
	self.focus();
}

function rowOverEffect(object) {
	if (object.className == 'moduleRow') {
		object.className = 'moduleRowOver';
	}
}

function rowOutEffect(object) {
	if (object.className == 'moduleRowOver') { 
		object.className = 'moduleRow';
	}
}

function checkBox(object) {
	document.account_notifications.elements[object].checked = !document.account_notifications.elements[object].checked;
}

function check_form_optional(form_name) {
	var form = form_name;
	
	var firstname = form.elements['firstname'].value;
	var lastname = form.elements['lastname'].value;
	var street_address = form.elements['street_address'].value;
	
	if (firstname == '' && lastname == '' && street_address == '') {
		return true;
	} else {
		return check_form(form_name);
	}
}

